package com.atqinke.designpattern.behavioraltype.command;

import java.util.Map;
import java.util.Set;

/**
 * @BelongsProject: BasicConnection
 * @BelongsPackage: com.atqinke.designpattern.behavioraltype.command
 * @Author: NieHk
 * @CreateTime: 2022-08-28  22:48
 * @Description: 命令
 * @Version: 1.0
 */
public class OrderCommand implements Command{

    //持有接受者对象
    private SeniorChef receiver;
    private Order order;

    public OrderCommand(SeniorChef receiver, Order order){
        this.receiver = receiver;
        this.order = order;
    }

    public void execute()  {
        System.out.print( order.getDiningTable() + "号桌的订单：  ");
        Set<Map.Entry<String, Integer>> entrySet = order.getFoodDic().entrySet();
        for (Map.Entry<String, Integer> entry : entrySet) {
            receiver.makeFood(entry.getValue(),entry.getKey());
        }

        try {
            Thread.sleep(100);//停顿一下 模拟做饭的过程
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("");
        System.out.println(order.getDiningTable() + "桌的饭弄好了");
    }
}
